/**
 * 
 */
package org.jrm.mechanics;

import java.util.HashMap;

import org.jrm.map.Wall;

/**
 * @author LAP
 *
 */
public class GameItemFactory {
	
	private HashMap<Integer, GameItem> collisionMapFlyweightConteiner;
	
	private GameItemFactory() {
		collisionMapFlyweightConteiner = new HashMap<Integer, GameItem>();
	}
	
	private static class GameItemFactoryHolder {
		public static GameItemFactory instance = new GameItemFactory();
	}
	
	public static GameItemFactory getInstance() {
		return GameItemFactoryHolder.instance;
	}
	
	public GameItem getMapItem(int health) {
		GameItem mapItem = collisionMapFlyweightConteiner.get((Integer)health);
		if (mapItem == null) {
			mapItem = new Wall(health);
			collisionMapFlyweightConteiner.put((Integer)health, mapItem);
		}
		return mapItem;
	}
}
